package com.taxi.driver.module.main.mine.message.details;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;

import com.taxi.driver.R;
import com.taxi.driver.common.BaseActivity;
import com.taxi.driver.module.vo.MessageVO;

/**
 * 消息详情
 */
public class MessageDetailsActivity extends BaseActivity {

    public static final String MESSAGE_DETAILS = "MESSAGE_DETAILS";

    public static void start(Context context, MessageVO vo) {
        Intent starter = new Intent(context, MessageDetailsActivity.class);
        starter.putExtra(MESSAGE_DETAILS, vo);
        context.startActivity(starter);
    }

    MessageDetailsFragment mMessageDetailsFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message_details);

        if (mMessageDetailsFragment == null) {
            mMessageDetailsFragment = MessageDetailsFragment.newInstance((MessageVO) getIntent().getSerializableExtra(MESSAGE_DETAILS));
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.add(R.id.fragment_container, mMessageDetailsFragment);
            transaction.commit();
        }
    }

    @Override
    public void onAttachFragment(Fragment fragment) {
        super.onAttachFragment(fragment);
        if (fragment instanceof MessageDetailsFragment) {
            mMessageDetailsFragment = (MessageDetailsFragment) fragment;
        }
    }
}
